package com.lsh.payment.core.service.config;

import com.lsh.payment.core.dao.config.PayConfigMapper;
import com.lsh.payment.core.model.config.PayConfig;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
 * Project Name: lsh-payment
 *
 * @author by peter on 17/12/22.
 * 北京链商电子商务有限公司
 * Package
 * desc:
 */
@Service
public class ConfigService {

    @Autowired
    private PayConfigMapper payConfigDao;

    @Transactional(rollbackFor = Exception.class, readOnly = true)
    public PayConfig getConfigOne(Integer configId) {

        return payConfigDao.selectByPrimaryKey(configId);
    }

    @Transactional(rollbackFor = Exception.class)
    public int addConfig(PayConfig config) {

        return payConfigDao.insertSelective(config);
    }

    @Transactional(rollbackFor = Exception.class)
    public int updateConfig(PayConfig config) {
        config.setId(1);
        config.setIsValid(1);
        config.setConfigType(1);

        return payConfigDao.updateByPrimaryKeySelective(config);
    }

}
